﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace eShop.DataAccess.Converter
{
    public class AddressConverter
    {
        public static List<Model.Address> ConvertToModelObject(List<Entity.Address> entities)
        {
            List<Model.Address> models = new List<Model.Address>(entities.Count);
            foreach (Entity.Address entity in entities)
            {
                models.Add(ConvertToModelObject(entity));
            }
            return models;
        }

        public static Model.Address ConvertToModelObject(Entity.Address entity)
        {
            if (entity == null) return null;
            Model.Address model = new Model.Address();
            model.Id = entity.Id;
            model.UserId = entity.UserId;
            model.Name = entity.Name;
            model.PhoneNumber = entity.PhoneNumber;
            model.AddressLine1 = entity.AddressLine1;
            model.AddressLine2 = entity.AddressLine2;
            model.Zip = entity.Zip;
            model.City = entity.City;
            model.State = entity.State;
            model.Country = entity.Country;
            return model;
        }

        public static Entity.Address ConvertToEntity(Model.Address model)
        {
            Entity.Address entity = new Entity.Address();
            entity.Id = model.Id;
            entity.UserId = model.UserId;
            entity.Name = model.Name;
            entity.PhoneNumber = model.PhoneNumber;
            entity.AddressLine1 = model.AddressLine1;
            entity.AddressLine2 = model.AddressLine2;
            entity.Zip = model.Zip;
            entity.City = model.City;
            entity.State = model.State;
            entity.Country = model.Country;
            return entity;
        }

    }
}
